<div class="controls">
	<div id="uploader_{$id}" style="padding-bottom: 5px;">选择文件</div><!-- 上传按钮 -->
	<input type="hidden" name="{$id}" value="{$value}" id="file_upload_{$id}">
	<div id="file_list_{$id}">
		{notempty name="files"}
		    {volist name="files" id="vo"}
		        <div>
			        {$vo.name}
			        <a onclick="del_file_{$id}(this, {$vo.id})"><i class="fa fa-trash"></i></a>
		        </div>
		    {/volist}
	    {/notempty}
	</div>
</div>
<script type="text/javascript">
    $(function(){
        var uploader_{$id} = WebUploader.create({
            swf: '__STATIC__/webuploader/js/uploader.swf',
            server: "{:url('core/File/uploadFile')}",
            pick: "#uploader_{$id}",
            resize: false
        });

        uploader_{$id}.on('fileQueued', function(file) { // 上传队列
            uploader_{$id}.upload();

            toast.showLoading();
        });
        uploader_{$id}.on('uploadSuccess', function(file, ret) { // 上传成功 file[name,id]
            if ( ret.status==1 ) {
                toast.success("上传成功");

                $('#file_list_{$id}').append('<div>'+ret.data.file.name+' <a onclick="del_file_{$id}'+'(this, '+ret.data.file.id+')"><i class="icon-trash"></i></a></div>');
                upAttachVal($('#file_upload_{$id}'), 'add', ret.data.file.id);
            } else {
                toast.error("上传失败"+ret.info);
            }
        });
        uploader_{$id}.on('uploadError', function(file) {
            toast.error("上传失败");
        });
        uploader_{$id}.on('uploadComplete', function(file) {
            toast.hideLoading();
        });
        $("#uploader_{$id}").find(".webuploader-pick").last().css({
            width: "64px",
            height: "26px"
        });
    });

    function del_file_{$id}(obj, attachId) {
        upAttachVal($('#file_upload_{$id}'), 'del', attachId);
        $(obj).parent('div').remove();
    }
</script>